import { Tooltip } from 'antd';
import { tableSorter, tooltipLength, priceFormat } from '@/utils';
import pageStyles from '@/common/pageLayout.less';

const getTableColumns = (curRes: Record<string, any>, clickFnc, styleName: string) => {
  let tableConfig = [
    {
      title: '申请部门/单位',
      dataIndex: 'departmentName',
      key: 'departmentName',
      width: 190,
      visible: true,
      fixed: 'left',
      unDrag: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'departmentID'),
      render: (text: number | any, record: Record<string, any>) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text || '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '合同数',
      dataIndex: 'totalNum',
      key: 'totalNum',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'totalNum'),
      // render: (text: string | null) => {
      //   return <span className={pageStyles['over-flow-hidden']}>{text ? text : 0}</span>;
      // },
      render: (text: number | any, record: Record<string, any>) => {
        return (
          <div className={`${styleName}titleBox`}>
            <a
              onClick={() => {
                clickFnc?.onView(record);
              }}
              style={{ color: '100%' }}
            >
              <span>{text ? text : 0}</span>
            </a>
          </div>
        );
      },
    },
    {
      title: '合同总金额（元）',
      dataIndex: 'totalSum',
      key: 'totalSum',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'totalSum'),
      render: (text: string | null) => {
        return <span className={pageStyles['over-flow-hidden']}>{text ? `${priceFormat(text)}` : '0.00'}</span>;
      },
    },

    {
      title: '合同已付金额（元）',
      dataIndex: 'totalPaid',
      key: 'totalPaid',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'totalPaid'),
      render: (text: string | null) => {
        return <span className={pageStyles['over-flow-hidden']}>{text ? `${priceFormat(text)}` : '0.00'}</span>;
      },
    },
    {
      title: '合同未付金额（元）',
      dataIndex: 'totalResidue',
      key: 'totalResidue',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'totalResidue'),
      render: (text: string | null) => {
        return <span className={pageStyles['over-flow-hidden']}>{text ? `${priceFormat(text)}` : '0.00'}</span>;
      },
    },
  ];

  return tableConfig;
};

export { getTableColumns };
